package com.cn.ysf.newbeemall.controller.admin;

import com.cn.ysf.newbeemall.service.NewBeeMallGoodsService;
import com.cn.ysf.newbeemall.util.PageQueryUtil;
import com.cn.ysf.newbeemall.util.Result;
import com.cn.ysf.newbeemall.util.ResultGenerator;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import sun.misc.Request;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author ysf
 * @date 2019/12/15 20:05
 */
@Controller
@RequestMapping("admin")
public class NewBeeManageController {

    @Resource
    private NewBeeMallGoodsService newBeeMallGoodsService;
    /**
     * 商品管理页面
     * @return
     */
    @RequestMapping("/goods/goodsmanage")
    public String togoodsmanage(HttpServletRequest request){
        request.setAttribute("path","goodsmanage");
        return "admin/goodsmanage";
    }


    @RequestMapping(value = "/goods/list", method = RequestMethod.GET)
    @ResponseBody
    public Result getlist(@RequestParam Map<String,Object> params){
        if(StringUtils.isEmpty(params.get("page")) || StringUtils.isEmpty(params.get("limit"))){
            return ResultGenerator.genFailResult("参数异常！");
        }
        PageQueryUtil pageUtil = new PageQueryUtil(params);
        return ResultGenerator.genSuccessResult(newBeeMallGoodsService.getNewBeeMallGoodsPage(pageUtil));
    }



}
